﻿<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >

<mapper namespace="${daoPackage!"com.dao"}.${tableCode}Dao"> 
	<!-- 查询${tableName}列表 -->
	<select id="get${tableCode}List"  resultType="${tableCode}">
    	select <#list items as item>${item.columnCode}<#if item_has_next>,</#if></#list> from ${table} 
	</select>
	<!-- 根据主键查询${tableName} -->
	<select id="get${tableCode}ById"  resultType="${tableCode}">
    	select * from ${table} where ${items[0].columnCode}=<#noparse>#</#noparse>{${items[0].columnCode}}
	</select>
  	<!-- 根据主键删除${tableName} -->
	<delete id="del${tableCode}ById">
  		delete from ${table} where ${items[0].columnCode}=<#noparse>#</#noparse>{${items[0].columnCode}}
	</delete>
	<!--新增${tableName}  -->
	<insert id="add${tableCode}" keyProperty="${items[0].columnCode}" useGeneratedKeys="true">
  		insert into ${table}(<#list items as item><#if item_index!=0>${item.columnCode}<#if item_has_next>,</#if></#if></#list>) 
  		values(<#list items as item><#if item_index!=0><#noparse>#</#noparse>{${item.columnCode}}<#if item_has_next>,</#if></#if></#list>)
	</insert>
  
</mapper>